<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Coverage for c:\program files\python26\lib\userdict</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
function toggle_lines(btn, cls) {
    var btn = $(btn);
    var hide = "hide_"+cls;
    if (btn.hasClass(hide)) {
        $("#source ."+cls).removeClass(hide);
        btn.removeClass(hide);
    }
    else {
        $("#source ."+cls).addClass(hide);
        btn.addClass(hide);
    }
}
</script>
</head>
<body>
<div id='header'>
    <div class='content'>
        <h1>Coverage for <b>c:\program files\python26\lib\userdict</b> :
            <span class='pc_cov'>2%</span>
        </h1>
        <h2 class='stats'>
            155 statements
            <span class='run hide_run' onclick='toggle_lines(this, "run")'>3 run</span>
            <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
            <span class='mis' onclick='toggle_lines(this, "mis")'>152 missing</span>
            
                <span class='par run hide_run' onclick='toggle_lines(this, "par")'>2 partial</span>
            
        </h2>
    </div>
</div>

<div id='source'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td class='linenos' valign='top'>
<p class='pln'>1</p>
<p class='pln'>2</p>
<p class='stm mis'>3</p>
<p class='stm mis'>4</p>
<p class='stm run hide_run'>5</p>
<p class='stm par run hide_run'>6</p>
<p class='stm mis'>7</p>
<p class='stm par run hide_run'>8</p>
<p class='stm mis'>9</p>
<p class='stm mis'>10</p>
<p class='stm mis'>11</p>
<p class='stm mis'>12</p>
<p class='stm mis'>13</p>
<p class='pln'>14</p>
<p class='stm mis'>15</p>
<p class='stm mis'>16</p>
<p class='stm mis'>17</p>
<p class='stm mis'>18</p>
<p class='stm mis'>19</p>
<p class='stm mis'>20</p>
<p class='stm mis'>21</p>
<p class='stm mis'>22</p>
<p class='stm mis'>23</p>
<p class='stm mis'>24</p>
<p class='stm mis'>25</p>
<p class='stm mis'>26</p>
<p class='stm mis'>27</p>
<p class='stm mis'>28</p>
<p class='stm mis'>29</p>
<p class='stm mis'>30</p>
<p class='stm mis'>31</p>
<p class='stm mis'>32</p>
<p class='stm mis'>33</p>
<p class='pln'>34</p>
<p class='stm mis'>35</p>
<p class='stm mis'>36</p>
<p class='stm mis'>37</p>
<p class='stm mis'>38</p>
<p class='stm mis'>39</p>
<p class='stm mis'>40</p>
<p class='stm mis'>41</p>
<p class='stm mis'>42</p>
<p class='stm mis'>43</p>
<p class='stm mis'>44</p>
<p class='stm mis'>45</p>
<p class='stm mis'>46</p>
<p class='stm mis'>47</p>
<p class='stm mis'>48</p>
<p class='stm mis'>49</p>
<p class='stm mis'>50</p>
<p class='stm mis'>51</p>
<p class='pln'>52</p>
<p class='stm mis'>53</p>
<p class='stm mis'>54</p>
<p class='stm mis'>55</p>
<p class='stm mis'>56</p>
<p class='stm mis'>57</p>
<p class='stm mis'>58</p>
<p class='stm mis'>59</p>
<p class='stm mis'>60</p>
<p class='stm mis'>61</p>
<p class='stm mis'>62</p>
<p class='stm mis'>63</p>
<p class='stm mis'>64</p>
<p class='stm mis'>65</p>
<p class='stm mis'>66</p>
<p class='stm mis'>67</p>
<p class='stm mis'>68</p>
<p class='stm mis'>69</p>
<p class='stm mis'>70</p>
<p class='stm mis'>71</p>
<p class='stm mis'>72</p>
<p class='stm mis'>73</p>
<p class='stm mis'>74</p>
<p class='stm mis'>75</p>
<p class='stm mis'>76</p>
<p class='pln'>77</p>
<p class='stm mis'>78</p>
<p class='stm mis'>79</p>
<p class='stm mis'>80</p>
<p class='pln'>81</p>
<p class='stm mis'>82</p>
<p class='stm mis'>83</p>
<p class='pln'>84</p>
<p class='pln'>85</p>
<p class='stm mis'>86</p>
<p class='pln'>87</p>
<p class='pln'>88</p>
<p class='pln'>89</p>
<p class='pln'>90</p>
<p class='pln'>91</p>
<p class='pln'>92</p>
<p class='pln'>93</p>
<p class='pln'>94</p>
<p class='stm mis'>95</p>
<p class='stm mis'>96</p>
<p class='stm mis'>97</p>
<p class='stm mis'>98</p>
<p class='stm mis'>99</p>
<p class='stm mis'>100</p>
<p class='stm mis'>101</p>
<p class='stm mis'>102</p>
<p class='stm mis'>103</p>
<p class='stm mis'>104</p>
<p class='stm mis'>105</p>
<p class='pln'>106</p>
<p class='pln'>107</p>
<p class='stm mis'>108</p>
<p class='stm mis'>109</p>
<p class='stm mis'>110</p>
<p class='stm mis'>111</p>
<p class='stm mis'>112</p>
<p class='pln'>113</p>
<p class='pln'>114</p>
<p class='stm mis'>115</p>
<p class='stm mis'>116</p>
<p class='stm mis'>117</p>
<p class='stm mis'>118</p>
<p class='stm mis'>119</p>
<p class='stm mis'>120</p>
<p class='stm mis'>121</p>
<p class='stm mis'>122</p>
<p class='stm mis'>123</p>
<p class='stm mis'>124</p>
<p class='stm mis'>125</p>
<p class='stm mis'>126</p>
<p class='stm mis'>127</p>
<p class='stm mis'>128</p>
<p class='stm mis'>129</p>
<p class='stm mis'>130</p>
<p class='stm mis'>131</p>
<p class='stm mis'>132</p>
<p class='stm mis'>133</p>
<p class='pln'>134</p>
<p class='stm mis'>135</p>
<p class='stm mis'>136</p>
<p class='stm mis'>137</p>
<p class='stm mis'>138</p>
<p class='stm mis'>139</p>
<p class='stm mis'>140</p>
<p class='stm mis'>141</p>
<p class='stm mis'>142</p>
<p class='stm mis'>143</p>
<p class='stm mis'>144</p>
<p class='stm mis'>145</p>
<p class='stm mis'>146</p>
<p class='stm mis'>147</p>
<p class='stm mis'>148</p>
<p class='stm mis'>149</p>
<p class='stm mis'>150</p>
<p class='pln'>151</p>
<p class='stm mis'>152</p>
<p class='stm mis'>153</p>
<p class='stm mis'>154</p>
<p class='stm mis'>155</p>
<p class='stm mis'>156</p>
<p class='stm mis'>157</p>
<p class='stm mis'>158</p>
<p class='stm mis'>159</p>
<p class='pln'>160</p>
<p class='stm mis'>161</p>
<p class='stm mis'>162</p>
<p class='stm mis'>163</p>
<p class='stm mis'>164</p>
<p class='stm mis'>165</p>
<p class='stm mis'>166</p>
<p class='stm mis'>167</p>
<p class='stm mis'>168</p>
<p class='stm mis'>169</p>
<p class='stm mis'>170</p>
<p class='stm mis'>171</p>
<p class='stm mis'>172</p>
<p class='stm mis'>173</p>
<p class='stm mis'>174</p>
<p class='stm mis'>175</p>
<p class='stm mis'>176</p>
<p class='stm mis'>177</p>
<p class='stm mis'>178</p>
<p class='stm mis'>179</p>
    
</td>
<td class='text' valign='top'>
<p class='pln'><span class='str'>&quot;&quot;&quot;A more or less complete user-defined wrapper around dictionary objects.&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>UserDict</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>7</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>dict</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm par run hide_run'><span class='annotate' title='no jump to this line number'>9</span>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>repr</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__cmp__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='nam'>UserDict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>cmp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>cmp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__len__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__getitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>__class__</span><span class='op'>,</span> <span class='str'>&quot;__missing__&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>__class__</span><span class='op'>.</span><span class='nam'>__missing__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>KeyError</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__setitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>item</span><span class='op'>)</span><span class='op'>:</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>item</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__delitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>del</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>clear</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>clear</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>copy</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>__class__</span> <span class='key'>is</span> <span class='nam'>UserDict</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>UserDict</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>copy</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>copy</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>data</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span> <span class='op'>=</span> <span class='nam'>copy</span><span class='op'>.</span><span class='nam'>copy</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span> <span class='op'>=</span> <span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>c</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>c</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>keys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>items</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iteritems</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iterkeys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>iterkeys</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>itervalues</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>itervalues</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>values</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>values</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>has_key</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dict</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>dict</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>pass</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='nam'>UserDict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='nam'>type</span><span class='op'>(</span><span class='op'>{</span><span class='op'>}</span><span class='op'>)</span><span class='op'>)</span> <span class='key'>or</span> <span class='key'>not</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>,</span> <span class='str'>&#39;items&#39;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span><span class='op'>,</span> <span class='nam'>v</span> <span class='key'>in</span> <span class='nam'>dict</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>v</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>failobj</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>key</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>failobj</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setdefault</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>failobj</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>key</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>failobj</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>pop</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>pop</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>popitem</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>.</span><span class='nam'>popitem</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__contains__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>classmethod</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>fromkeys</span><span class='op'>(</span><span class='nam'>cls</span><span class='op'>,</span> <span class='nam'>iterable</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span> <span class='op'>=</span> <span class='nam'>cls</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>iterable</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>d</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>d</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>IterableUserDict</span><span class='op'>(</span><span class='nam'>UserDict</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__iter__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>iter</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>data</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>import</span> <span class='nam'>_abcoll</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_abcoll</span><span class='op'>.</span><span class='nam'>MutableMapping</span><span class='op'>.</span><span class='nam'>register</span><span class='op'>(</span><span class='nam'>IterableUserDict</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>DictMixin</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># Mixin defining all dictionary methods for classes that already have</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># a minimum dictionary interface including getitem, setitem, delitem,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># and keys. Without knowledge of the subclass constructor, the mixin</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># does not define __init__() or copy().&nbsp; In addition to the four base</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># methods, progressively more efficiency comes with defining</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># __contains__(), __iter__(), and iteritems().</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># second level definitions support higher levels</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__iter__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>k</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>has_key</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>value</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>False</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>True</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__contains__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>has_key</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># third level takes advantage of second level definitions</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iteritems</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='op'>(</span><span class='nam'>k</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>iterkeys</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>__iter__</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># fourth level uses definitions from lower levels</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>itervalues</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>_</span><span class='op'>,</span> <span class='nam'>v</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>yield</span> <span class='nam'>v</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>values</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='op'>[</span><span class='nam'>v</span> <span class='key'>for</span> <span class='nam'>_</span><span class='op'>,</span> <span class='nam'>v</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>items</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>clear</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>key</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>setdefault</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>pop</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span> <span class='op'>&gt;</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>,</span> <span class='str'>&quot;pop expected at most 2 arguments, got &quot;</span><span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='op'>+</span> <span class='nam'>repr</span><span class='op'>(</span><span class='num'>1</span> <span class='op'>+</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>value</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>popitem</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>k</span><span class='op'>,</span> <span class='nam'>v</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>next</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>StopIteration</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>KeyError</span><span class='op'>,</span> <span class='str'>&#39;container is empty&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>del</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='op'>(</span><span class='nam'>k</span><span class='op'>,</span> <span class='nam'>v</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>other</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Make progressively weaker assumptions about &quot;other&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>other</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>pass</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>other</span><span class='op'>,</span> <span class='str'>&#39;iteritems&#39;</span><span class='op'>)</span><span class='op'>:</span>&nbsp; <span class='com'># iteritems saves memory and lookups</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span><span class='op'>,</span> <span class='nam'>v</span> <span class='key'>in</span> <span class='nam'>other</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>v</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>other</span><span class='op'>,</span> <span class='str'>&#39;keys&#39;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span> <span class='key'>in</span> <span class='nam'>other</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>other</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>k</span><span class='op'>,</span> <span class='nam'>v</span> <span class='key'>in</span> <span class='nam'>other</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>[</span><span class='nam'>k</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>v</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>kwargs</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>default</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>default</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>repr</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__cmp__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>other</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>other</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>other</span><span class='op'>,</span> <span class='nam'>DictMixin</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>other</span> <span class='op'>=</span> <span class='nam'>dict</span><span class='op'>(</span><span class='nam'>other</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>cmp</span><span class='op'>(</span><span class='nam'>dict</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>iteritems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>other</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__len__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>keys</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
    
</td>
</tr>
</table>
</div>

</body>
</html>
